package com.zhang;

import cn.hutool.core.util.StrUtil;
import com.zhang.common.config.GlobalConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ngrok 客户端
 * @author zhanghao
 */
public class NgrokClient {
    /**
     * 日志对象
     */
    static private Logger log = LoggerFactory.getLogger(NgrokClient.class);

    public static void main(String[] args) {
        //初始化配置文件
        GlobalConfig.init("client.properties");
        //检查配置
        checkConfig();
        //客户端简历连接
        TCPConnect tcpConnect = new TCPConnect();
        tcpConnect.connectNgrok();
    }

    private static void checkConfig() {
        String serverdomain = GlobalConfig.props.getStr("serverdomain");
        String localport = GlobalConfig.props.getStr("localport");
        String serverPort = GlobalConfig.props.getStr("serverPort");
        if(StrUtil.isBlank(serverdomain)){
            throw new RuntimeException("serverdomain不能为空");
        }
        if (StrUtil.isBlank(localport)){
            throw new RuntimeException("localport不能为空");
        }
        if (StrUtil.isBlank(serverPort)){
            throw new RuntimeException("serverPort不能为空");
        }
    }
}
